
using System;
using System.Collections;
using System.Web.UI.WebControls;

namespace GiftNet.Model
{
	#region TaskFile Model -(by fangyifeng at 2007-09-14 12:24:26)

	/// <summary>
	/// TaskFile object'TaskFiles'.
	/// </summary>
	[Serializable]
	public class TaskFile : System.IComparable
		{
		#region Member Variables
		
		protected Guid _id;
		protected FileInfo _fileInfo;
		protected SystemTask _task;
		protected SystemUser _uploadUser;
		
		protected static String _sortExpression = "Id";
		protected static SortDirection _sortDirection = SortDirection.Ascending;

		#endregion

		#region Constructors

		public TaskFile() { }

		public TaskFile( FileInfo fileInfo, SystemTask task, SystemUser uploadUser )
		{
			this._fileInfo = fileInfo;
			this._task = task;
			this._uploadUser = uploadUser;
		}

		#endregion

		#region Public Properties

		public virtual Guid Id
		{
			get {return _id;}
			set {_id = value;}
		}

		public virtual FileInfo FileInfo
		{
			get { return _fileInfo; }
			set { _fileInfo = value; }
		}

		
		public virtual SystemTask Task
		{
			get { return _task; }
			set { _task = value; }
		}

		
		public virtual SystemUser UploadUser
		{
			get { return _uploadUser; }
			set { _uploadUser = value; }
		}

		
        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
		#endregion
		
        #region IComparable Methods
        public virtual int CompareTo(object obj)
        {
			if (!(obj is TaskFile))
				throw new InvalidCastException("This object is not of type TaskFile");
			
			int relativeValue;
			switch (SortExpression)
			{
				case "Id":
					relativeValue = this.Id.CompareTo(((TaskFile)obj).Id);
					break;
                default:
                    goto case "Id";
			}
            if (TaskFile.SortDirection == SortDirection.Ascending)
				relativeValue *= -1;
			return relativeValue;
		}
		#endregion
	}

	#endregion
}
